home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 February
/
EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso
/
enigma
/
earcd
/
utility
/
utilhard
/
lcdaem18.lha
/
LCDaemon
/
Programmer
/
LCDtest
/
lcdtest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-13
|
2KB
|
90 lines
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <exec/ports.h>
#include <dos/dos.h>
#include "lcd.h"
struct MsgPort *replyport;
struct lcdmessage msg;
struct lcdparams lcdpar;
LONG time=100;
char text[100];
char message[100];
struct lcdirect commands[100];
int SafePutToPort(struct lcdmessage *message,STRPTR portname){
struct MsgPort *port;
Forbid();
port=FindPort(portname);
if(port) PutMsg(port,(struct Message *)message);
Permit();
return(port?TRUE:FALSE);
}
int main(int argc,char **argv){
LONG delay=100,from=0,to=256,i,j,k;
struct lcdirect *lcdir;
signal(SIGINT,SIG_IGN);
if((argc>=1)&&argv[1])StrToLong(argv[1],(LONG *)&from);
if((argc>=2)&&argv[2])StrToLong(argv[2],(LONG *)&to);
if((argc>=3)&&argv[3])StrToLong(argv[3],(LONG *)&delay);
if(replyport=CreateMsgPort()){
msg.lcd_Message.mn_Node.ln_Type=NT_MESSAGE;
msg.lcd_Message.mn_Length=sizeof(struct lcdmessage);
msg.lcd_Message.mn_ReplyPort=replyport;
msg.lcd_Priority=LCDPRI_APPLICATION;
msg.lcd_Code=LCDMSG_ASKPARAMS;
msg.lcd_Data=&lcdpar;
if(SafePutToPort(&msg,lcdportname)){
WaitPort(replyport);
GetMsg(replyport);
msg.lcd_Code=LCDMSG_ALLOCATELCD;
if(SafePutToPort(&msg,lcdportname)&&(WaitPort(replyport),GetMsg(replyport),!msg.lcd_Error)){
lcdir=commands;
msg.lcd_Code=LCDMSG_LCDIRECT;
msg.lcd_Data=lcdir;
lcdir->Command=LCDCMD_CLS;
lcdir++;
lcdir->Command=LCDCMD_DISPLAY;
lcdir->Data=ON;
lcdir++;
for(i=from;i<to;i+=lcdpar.width*lcdpar.height){
for(j=0;j<lcdpar.height;j++){
lcdir->Command=LCDCMD_GOTOXY;
lcdir->Data=(j<<16)&0xffff0000;
lcdir++;
for(k=0;k<lcdpar.width;k++){
lcdir->Command=LCDCMD_DATA;
lcdir->Data=i+j*lcdpar.width+k;
if(lcdir->Data<256)lcdir++;
}
}
lcdir->Command=LCDCMD_END;
SafePutToPort(&msg,lcdportname);
WaitPort(replyport);
GetMsg(replyport);
Delay(delay);
lcdir=commands;
lcdir->Command=LCDCMD_CLS;
lcdir++;
}
msg.lcd_Code=LCDMSG_FREELCD;
SafePutToPort(&msg,lcdportname);
WaitPort(replyport);
GetMsg(replyport);
}
}
DeleteMsgPort(replyport);
}
return(0);
}